map_dict = [
( "ABC", "2"),
("DEF" , "3"),
("GHI" , "4"),
("JKL" , "5") ,
("MNO" , "6"),
("PQRS" , "7"),
("TUV" ,"8"),
("WXYZ", "9"),
(" ", "#")
]

def getnumber(letter):
    global map_dict
    for x in map_dict:
        if letter in x[0]:
            return x[1] +  x[1]* x[0].index(letter)
    return letter

number = "Eve has a cat"
number = number.upper()
i=0
new_numb =""
while i < len(number):
    new_numb = new_numb + getnumber(number[i])
    i+=1

print new_numb 
